---
title: Logfire
description: Integrate Agno with Logfire to send traces and gain insights into your agent's performance.
---

## Integrating Agno with Logfire

[Logfire](https://logfire.dev/) is Pydantic's observability platform that provides comprehensive tracing and monitoring for AI applications. By integrating Agno with Logfire, you can utilize OpenInference to send traces and gain insights into your agent's performance.

## Prerequisites

1. **Install Dependencies**

   Ensure you have the necessary packages installed:

   ```bash
   pip install agno openai opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-agno
   ```

2. **Setup Logfire Account**

   - Sign up for an account at [Logfire](https://logfire.dev/).
   - Obtain your write token from the Logfire dashboard.

3. **Set Environment Variables**

   Configure your environment with the Logfire write token:

   ```bash
   export LOGFIRE_WRITE_TOKEN=<your-write-token>
   ```

## Sending Traces to Logfire

This example demonstrates how to instrument your Agno agent with OpenInference and send traces to Logfire.

```python
import os

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools
from openinference.instrumentation.agno import AgnoInstrumentor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

# Set environment variables for Logfire
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://logfire-eu.pydantic.dev"  # EU data region
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization={os.getenv('LOGFIRE_WRITE_TOKEN')}"

# Configure the tracer provider
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))

# Start instrumenting agno
AgnoInstrumentor().instrument(tracer_provider=tracer_provider)

# Create and configure the agent
agent = Agent(
    name="Stock Price Agent",
    model=OpenAIChat(id="gpt-5-mini"),
    tools=[DuckDuckGoTools()],
    instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
    debug_mode=True,
)

# Use the agent
agent.print_response("What is the current price of Tesla?")
```

## Notes

- **Environment Variables**: Ensure your environment variables are correctly set for the write token and OTLP endpoint.
- **Data Regions**: Adjust the `OTEL_EXPORTER_OTLP_ENDPOINT` for your data region. Available regions include:
  - `https://logfire-us.pydantic.dev` for the US region
  - `https://logfire-eu.pydantic.dev` for the EU region
- **Logfire Dashboard**: View your traces and monitor performance at [Logfire Dashboard](https://logfire.pydantic.dev/)

By following these steps, you can effectively integrate Agno with Logfire, enabling comprehensive observability and monitoring of your AI agents.

